package com.xvjialing.lytech.weatherreport.job;

import com.xvjialing.lytech.weatherreport.bean.CityData;
import com.xvjialing.lytech.weatherreport.net.WeatherDataService;
import com.xvjialing.lytech.weatherreport.service.CityCodeService;
import com.xvjialing.lytech.weatherreport.service.CityDataService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class WeatherDataSyncJob {

//    @Autowired
//    CityCodeService cityCodeService;
//
//    @Autowired
//    CityDataService cityDataService;
//
//    @Autowired
//    WeatherDataService weatherDataService;

    private Logger logger = LoggerFactory.getLogger(WeatherDataSyncJob.class);


//    @Scheduled(cron = "1 * * * * *")
//    private void task(){
//        logger.info("每分钟的第一秒触发");
//    }
//
//    @Scheduled(fixedRate = 1000*1)
//    private void task2(){
//        logger.info("上一个调用开始后再次调用的延时（不用等待上一次调用完成)");
//    }
//
//
//    @Scheduled(fixedDelay = 1000*1)
//    private void task3(){
//        logger.info("上一个调用完成后再次调用的延时（需要等待上一次调用完成)");
//    }
//
//    @Scheduled(initialDelay = 1000*10,fixedDelay = 1000*1)
//    private void task4(){
//        logger.info("initialDelay,第一次调用的延时");
//    }

//    @Scheduled(fixedDelay = 1000*1800)
//    private void syncWeatherData(){
//        List<CityData> cityDataList = cityDataService.getCityDataList();
//        for (CityData cityData:cityDataList){
////            logger.info("cityData:{}",cityData.getDescription());
////            weatherDataService.syncWeatherByCityName(cityData.getDescription());
//            weatherDataService.syncWeatherByCityCode(String.valueOf(cityData.getCode()));
//        }
//        logger.info("sync finish!");
//    }

}